package com.hsy.crm.web;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.MultipartConfigFactory;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.util.unit.DataSize;
import tk.mybatis.spring.annotation.MapperScan;

import javax.servlet.MultipartConfigElement;

@MapperScan(basePackages = {"com.hsy.crm.web.mapper"})
@SpringBootApplication
@EnableScheduling
public class CrmApplication extends SpringBootServletInitializer {
	
	public static void main(String[] args) {
		SpringApplication.run(CrmApplication.class,args);
	}

	@Bean
	public MultipartConfigElement multipartConfigElement() {
		MultipartConfigFactory factory = new MultipartConfigFactory();
		//允许上传的文件最大值		20M
		factory.setMaxFileSize(DataSize.ofBytes(1024*1024*20));
		/// 设置总上传数据总大小		2G
		factory.setMaxRequestSize(DataSize.ofBytes(1024*1024*1024*2));
		/*//设置临时文件路径，以防长时间不操作后删除临时文件导致报错
		File f = new File(tempfilePath);
		if (!f.exists())
			f.mkdirs();
		factory.setLocation(tempfilePath);*/
		return factory.createMultipartConfig();
	}

}